package cn.gok;

import java.util.*;

class Book {
    private int bid;
    private String bname;
    private float price;

    public Book() {
    }

    public Book(int bid, String bname, float price) {
        this.bid = bid;
        this.bname = bname;
        this.price = price;
    }

    @Override
    public String toString() {
        return "Book{" +
                "bid=" + bid +
                ", bname='" + bname + '\'' +
                ", price=" + price +
                '}';
    }

    public int getBid() {
        return bid;
    }

    public void setBid(int bid) {
        this.bid = bid;
    }

    public String getBname() {
        return bname;
    }

    public void setBname(String bname) {
        this.bname = bname;
    }

    public float getPrice() {
        return price;
    }

    public void setPrice(float price) {
        this.price = price;
    }
}

public class 作业六 {
    public static void main(String[] args) {
        Map<Book, String> treeMap = new TreeMap<>((o1, o2) -> {
            return Double.compare(o2.getPrice(), o1.getPrice());
        });
        treeMap.put(new Book(1, "西游记", 100f), "AA");
        treeMap.put(new Book(2, "东游记", 200f), "BB");
        treeMap.put(new Book(3, "红楼梦", 150f), "CC");
        treeMap.put(new Book(4, "水浒传", 700f), "DD");
        treeMap.put(new Book(5, "三国演义", 300f), "EE");
        for (Book b : treeMap.keySet()) {
            System.out.println(b);
        }
        treeMap.entrySet().stream().forEach(e -> {
            System.out.println(e.getKey());
        });
        System.out.println("-----------------------------");
        List<Book> list = new ArrayList<>();
        list.add(new Book(1, "西游记", 100f));
        list.add(new Book(2, "东游记", 200f));
        list.add(new Book(3, "红楼梦", 150f));
        list.add(new Book(4, "水浒传", 700f));
        list.add(new Book(5, "三国演义", 300f));
        list.stream().filter(f -> f.getPrice() < 150).sorted((o1, o2) -> o1.getBid() - o2.getBid()).forEach(f -> System.out.println(f));

    }
}
